import com.sfx.component.UserComponent;
import com.sfx.configuration.UserConfiguration;
import com.sfx.controller.*;
import com.sfx.model.User;
import com.sfx.repository.UserRepository;
import com.sfx.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Repository;

import javax.security.auth.login.Configuration;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;

public class App {
    //启动类
    public static void main(String[] args) {
        //获取到SpringContext上下文对象
        ApplicationContext context1 = new ClassPathXmlApplicationContext
                ("spring-config.xml");
        System.out.println("=================================");
        ScopeController1 scopeController1 = context1.getBean("scopeController1", ScopeController1.class);
        scopeController1.doScopeController1();
        System.out.println("=================================");
        ScopeController2 scopeController2 = context1.getBean("scopeController2", ScopeController2.class);
        scopeController2.doScopeController2();

//        BeanLifeComponent component = context.getBean("beanLife", BeanLifeComponent
//                .class);
//        component.use();
//        context.close();
//        ApplicationContext context =
//                new ClassPathXmlApplicationContext("spring-config.xml");
//        DogA dogA = context.getBean("dogA",DogA.class);
//        dogA.doDog();
//        System.out.println();
//        DogB dogB = context.getBean("dogB",DogB.class);
//        dogB.doDog();
//        ScopeControllerA scopeControllerA =
//                context.getBean("scopeControllerA",ScopeControllerA.class);
//        scopeControllerA.doScopeControllerA();
//        System.out.println();
//        ScopeControllerB scopeControllerB =
//                context.getBean("scopeControllerB",ScopeControllerB.class);
//        scopeControllerB.doScopeControllerB();

//       UserController userController = context.getBean("userController",
//               UserController.class);
//       userController.sayHello();
//       ScopeController scopeController = context.getBean("scopeController",ScopeController.class);
//       scopeController.doScope();
//       UserController2 userController2 = context.getBean("userController2",UserController2.class);
//       userController2.doController();
//        TestController testController = context.getBean("testController",TestController.class);
//        User user = testController.doTestController();
//        System.out.println(user.toString());
//        UserController3 userController3 = context.getBean("userController3",UserController3.class);
//        userController3.doUserController3();
//        //1.得到spring对象
//        ApplicationContext context =
//                new ClassPathXmlApplicationContext("spring-config.xml");
//
//        User user = context.getBean("user_bean",User.class);
//        System.out.println("userID : " + user.getId() + " UserName : " + user.getName());
//

////2.使用getBean获取bean
//        SController user =
//                context.getBean("SController", SController.class);
//        //3.使用bean
//        user.doController();
//        UserService userService = context.getBean("userService",UserService.class);
//
//        userService.doUserService();

//        UserRepository userRepository =
//                context.getBean("userRepository",UserRepository.class);
//        userRepository.doUserRepository();

//        UserComponent userComponent = context.getBean("userComponent",UserComponent.class);
//        userComponent.doUserComponent();
//        UserConfiguration userConfiguration = context.getBean("userConfiguration1",UserConfiguration.class);
//        userConfiguration.doUserConfiguration();
    }
}
